Solution:
a1 = 8 a2 = 8 * 2 n = 6 q = a2 / a1 s6 = a1 * ((1 - q**n) / (1 - q)) print(f'The sum of the first {n} elements of the sequence is: {s6}')